﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Wiki.WinClient
{
    public partial class ContentForm : Form
    {
        public ContentForm()
        {
            InitializeComponent();
        }
        private Point mouseOffset;        //记录鼠标指针的坐标

        private bool isMouseDown = false; //记录鼠标按键是否按下

        private void form1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {

            int xOffset;

            int yOffset;

            if (e.Button == MouseButtons.Left)
            {

                xOffset = -e.X;// -SystemInformation.FrameBorderSize.Width;

                yOffset = -e.Y;// -SystemInformation.CaptionHeight - SystemInformation.FrameBorderSize.Height;

                mouseOffset = new Point(xOffset, yOffset);

                isMouseDown = true;

            }

        }

        private void form1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {

            if (isMouseDown)
            {

                Point mousePos = Control.MousePosition;

                mousePos.Offset(mouseOffset.X, mouseOffset.Y);

                Location = mousePos;

            }

        }

        private void form1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
        {

            // 修改鼠标状态isMouseDown的值

            // 确保只有鼠标左键按下并移动时，才移动窗体

            if (e.Button == MouseButtons.Left)
            {

                isMouseDown = false;

            }

        }
        private void Obj_MouseHover(object sender, EventArgs e)
        {
            ((PictureBox)sender).BackColor = System.Drawing.Color.FromArgb(7, 38, 17);

        }

        private void Obj_MouseLeave(object sender, EventArgs e)
        {
            ((PictureBox)sender).BackColor = Color.Transparent;
        }
        int goX, goY;
        private void Obj_MouseDown(object sender, MouseEventArgs e)
        {
            goX = ((PictureBox)sender).Location.X;
            goY = ((PictureBox)sender).Location.Y;

            ((PictureBox)sender).Location = new Point(goX + 1, goY + 1);
        }

        private void Obj_MouseUp(object sender, MouseEventArgs e)
        {
            ((PictureBox)sender).Location = new Point(goX, goY);
        }

        private void ClosePicBox_Click(object sender, EventArgs e)
        {
            this.Close();
            this.Dispose();
        }

        private void EditPicBox_Click(object sender, EventArgs e)
        {
            this.TileTBox.Enabled = true;

            this.KeywordTBox.Enabled = true;

            this.ContentHEC.Enabled = true;
            
        }

        private void AddPicBox_Click(object sender, EventArgs e)
        {
            this.TileTBox.Text = "";
            this.TileTBox.Enabled = true;
            this.KeywordTBox.Text = "";
            this.KeywordTBox.Enabled = true;
            this.ContentHEC.InnerText = "";
            this.ContentHEC.Enabled = true;
            
        }

        private void SavePicBox_Click(object sender, EventArgs e)
        {
            var a = 10;
        }


    }
}
